const mongoose = require('mongoose')
const Koa = require('koa')
const app = new Koa()
const views = require('koa-views')
const { resolve } = require('path')
const { connect } = require('./database/init.js')
const MovieModel = require('./database/schema/movie.js')
const CategoryModel = require('./database/schema/category.js')
const UserModel = require('./database/schema/user.js')

;(async ()=>{
  await connect();
  const movies = await Movie.find({})
  console.log(movies)
})()

app.use(views(resolve(__dirname,'./views'),{
  extension: 'pug'
}))

app.use(async (ctx, next) => {
  await ctx.render('index',{
    you:'谢海涛',
    me:'koa2'
  })
})


app.listen(3000)